// packageJ/supportCenter/supportCenterVerifier/supportCenterVerifier.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value: "",
    info: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: '核销',
    })
    this.setData({
      options: options
    })
    if (options.scene) {
      let scene = decodeURIComponent(options.scene);
      if (scene) {
        var info_arr = [];
        info_arr = scene.split(',');
        for (let i = 0; i < info_arr.length; i++) {
          let chil_arr = [];
          chil_arr = info_arr[i].split('=');
          if (chil_arr[0] == "log_id") {
            this.setData({
              'options.log_id':chil_arr[1]
            })
          }
        }
      }
    }
    this.getData();
  },
  getData() {
    app._postNetWork({
      url: app.getNetAddresss("plugin.support-center.frontend.withdraw.write-off-page"),
      data: {
        log_id: this.data.options.log_id,
      },
      success: (resdata) => {
        let res = resdata.data;
        if (res.result == 1) {
          this.setData({
            info: res.data,
            value: res.data.withdraw_money
          })
        } else {
          app.tips(res.msg)
        }
      },
      fail: function (res) {
        console.log(res.msg);
      }
    });
  },
  actionTag(){
    app._postNetWork({
      url: app.getNetAddresss("plugin.support-center.frontend.withdraw.write-off-action"),
      data: {
        withdraw_money: this.data.value,
        log_id: this.data.options.log_id
      },
      success: (resdata) => {
        let res = resdata.data;
        if (res.result == 1) {
          app.tips("核销成功");
          this.getData();
        } else {
          app.tips(res.msg)
        }
      },
      fail: function (res) {
        console.log(res.msg);
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})